package test;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import dsa.*;

public class AbrahamVargasTest {

	LinkedList people;

	@Before
	public void setUp() throws Exception {

		people = new LinkedList();

		people.addFirst("Abe");
		people.addLast("Amaris");
		people.addLast("Jose");
		
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void indexOfTest() {
		people.addFirst("Sarah");
		people.addFirst("Ryan");
		assertFalse(people.indexOf("Sarah")==0);
		assertTrue(people.indexOf("Ryan")==0);
		assertTrue(people.indexOf("Sarah")==1);
		people.addLast("Jane");
		assertTrue(people.indexOf("Jane")==5);
	}
	
	@Test
	public void indexOfTest2(){
		people.addLast("Angela");
		assertTrue(people.indexOf("Angela") == 3);
		people.remove(2);
		assertTrue(people.indexOf("Angela")==2);
	}

	@Test
	public void firstIsFirstTest() {

		people.addFirst("Jim");
		assertTrue(people.get(0).equals("Jim"));

	}

	@Test
	public void LastIsLastTest() {
		people.addLast("Domenique");
		assertTrue(people.get(people.size() - 1).equals("Domenique"));
	}
	
	@Test
	public void getTest(){
		people.addFirst("Sean");
		assertTrue(people.get(1).equals("Abe"));
	}
	
	@Test
	public void getFirstTest(){
		people.addFirst("Jane");
		people.addLast("Haley");
		people.addFirst("Jared");
		assertTrue(people.getFirst().equals("Jared"));
	}
	
	@Test
	public void getLastTest(){
		people.addFirst("Jane");
		people.addLast("Haley");
		people.addFirst("Jared");
		assertTrue(people.getLast().equals("Haley"));
	}
	
	@Test
	public void setTest(){
		people.set(0, "Amanda");
		assertTrue(people.get(0).equals("Amanda"));
		assertTrue(people.get(1).equals("Amaris"));
	}

	@Test
	public void removeTest() {

		assertTrue(people.size() == 3);
		people.remove(1);
		assertTrue(people.size() == 2);

	}

	@Test
	public void sizeTest() {
		people.addLast("Merrily");
		assertTrue(people.size() == 4);
	}
	
	@Test
	public void toArrayTest()
	{
		Object[] array = people.toArray();		
		for(int i = 0; i < people.size(); i ++){
			assertTrue(array[i].equals(people.get(i)));
		}
	}
	
	@Test
	public void containsTest(){
	LinkedList container = new LinkedList();
	Object bob = "Bob";
	container.addFirst(bob);
	assertEquals(container.contains("Bob"),true);
	}
}
